﻿using System.Collections.Generic;
using log4net;

namespace Truncation.Detector.Win32
{
    internal class Report
    {
        private static readonly ILog Log = LogManager.GetLogger("Detail.Reporter");
        private readonly Dictionary<string, List<Result>>  _issues = new Dictionary<string, List<Result>>();

        public void Add(string fileName, Result result)
        {
            if (_issues.ContainsKey(fileName))
            {
                _issues[fileName].Add(result);
            }
            else
            {
                _issues.Add(fileName, new List<Result>(){result});
            }
        }

        public void Output()
        {
            foreach (var issue in _issues)
            {
                var fileName = issue.Key;
                foreach (var result in issue.Value)
                {
                    Log.InfoFormat("{0},{1}", fileName, result.ToString());
                }
            }
        }
    }
}
